package view;

import java.util.Observable;

public class Picasso extends Observable implements Runnable {

    private Draw tela;
    private int FPS;
    

    public Picasso() {
        this.FPS = 0;
    }

    @Override
    public void run() {
        long tempoInicio, tempoFim;
        tempoInicio = System.currentTimeMillis();
        while (true) {
            tela.repaint();
            this.FPS++;
            tempoFim = System.currentTimeMillis();
            if((tempoFim - tempoInicio) >= 1000){
                tempoInicio = tempoFim;
                notifica();
//                System.out.println("Notificou e zerou!");
                this.FPS = 0;
            }
        }
    }

    public void setTela(Draw tela) {
        this.tela = tela;
    }
    
    public int getFPS(){
        return this.FPS;
    }
            
    private void notifica() {
        setChanged();
        notifyObservers();
    }
}
